package cn.yh.action;

import cn.yh.biz.UserBiz;
import cn.yh.model.User;


public class LoginAction extends BaseAction{
	private String uname;
	private String pwd;
	
	public String execute(){
		UserBiz ub = new UserBiz();
		User user = ub.userLogin(this.uname, this.pwd);
		//System.out.println(user.getUname());
		if(user!=null){
			getSession().setAttribute("user",user);
			return "success";
		}else{
			return "fail";
		}
		
		
		/*if("admin".equals(this.uname)&&"admin".equals(this.pwd)){
			// 解耦 ActionContext.getContext().getSession().put("uname", uname);
			//耦合
			HttpServletRequest req = ServletActionContext.getRequest();
			req.setAttribute("uname", uname);
			getSession().setAttribute("uname",uname);
			
			return "success";
		}else{
			return "fail";
		}		
	*/

	}
	public String getUname() {
		return uname;
	}


	public void setUname(String uname) {
		this.uname = uname;
	}


	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}
	
}
